#ifndef _NFS_H_
#define _NFS_H_

#define FUSE_USE_VERSION 26
#include "ddriver.h"
#include "errno.h"
#include "fuse.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "types.h"
#include <assert.h>
#include <fcntl.h>
#include <stddef.h>
#include <unistd.h>

#define NFS_MAGIC 0x12345678  /* 请根据需要定义 */
#define NFS_DEFAULT_PERM 0777 /* 全权限打开 */

/******************************************************************************
* SECTION: macro debug
*******************************************************************************/
#define SFS_DBG(fmt, ...) do { printf("SFS_DBG: " fmt, ##__VA_ARGS__); } while(0) 
/******************************************************************************
 * SECTION: nfs_utils.c
 *******************************************************************************/
char *nfs_get_fname(const char *path);
int nfs_calc_lvl(const char *path);
int nfs_driver_read(int offset, char *buf, int size);
int nfs_driver_write(int offset, char *buf, int size);
int nfs_mount(struct custom_options options);
int nfs_umount();
void nfs_alloc_dblk(char **bpt, int *bno);
struct nfs_dentry *new_dentry(char *name, int type, int ino);
struct nfs_inode *nfs_alloc_inode(struct nfs_dentry *dentry, int type);
struct nfs_inode *get_inode_from_dentry(struct nfs_dentry *dentry);
void write_back_recurse(struct nfs_dentry *dentry);
struct nfs_dentry *nfs_lookup(const char *path, int *is_find, int *is_root);
struct nfs_dentry* nfs_get_dentry(struct nfs_inode * inode, int dir);

/******************************************************************************
 * SECTION: nfs.c
 *******************************************************************************/
void *nfs_init(struct fuse_conn_info *);
void nfs_destroy(void *);
int nfs_mkdir(const char *, mode_t);
int nfs_getattr(const char *, struct stat *);
int nfs_readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *);
int nfs_mknod(const char *, mode_t, dev_t);
int nfs_write(const char *, const char *, size_t, off_t, struct fuse_file_info *);
int nfs_read(const char *, char *, size_t, off_t, struct fuse_file_info *);
int nfs_access(const char *, int);
int nfs_unlink(const char *);
int nfs_rmdir(const char *);
int nfs_rename(const char *, const char *);
int nfs_utimens(const char *, const struct timespec tv[2]);
int nfs_truncate(const char *, off_t);
int nfs_open(const char *, struct fuse_file_info *);
int nfs_opendir(const char *, struct fuse_file_info *);

#endif /* _NFS_H_ */